package com.yj.suncity.utis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.yj.suncity.bean.ProvinceBean;

public class ProvinceManager {
	
	private static ProvinceManager manager;
	
	private static Map<String, List<ProvinceBean>> provinceMap;
	private static Map<String, List<ProvinceBean>> cityMap;
	private static Map<String, List<ProvinceBean>> countyMap;
	private static Map<String, Map<String, List<ProvinceBean>>> map;
	
	
	public synchronized static ProvinceManager getInstance(){
		if (manager==null) {
			manager = new ProvinceManager();
			provinceMap=new HashMap<String, List<ProvinceBean>>();
			cityMap=new HashMap<String, List<ProvinceBean>>();
			countyMap=new HashMap<String, List<ProvinceBean>>();
			map=new HashMap<String, Map<String,List<ProvinceBean>>>();
		}
		return manager;
	}
	
	public  void addProvicen(List<ProvinceBean> value){
		if (provinceMap==null) {
			provinceMap = new HashMap<String, List<ProvinceBean>>();
		}
		provinceMap.put("province", value);
	}
	public List<ProvinceBean> getProvincen(){
		if (provinceMap==null) {
			return null;
		}
		return provinceMap.get("province");
	}
	
	
	public void addCity(String key,List<ProvinceBean> value){
		if (cityMap==null) {
			cityMap = new HashMap<String, List<ProvinceBean>>();
		}
		cityMap.put(key, value);
	}
	public  List<ProvinceBean> getCity(String key){
		if (cityMap==null) {
			return null;
		}
		return cityMap.get(key);
	}
	
	/**
	 * 添加县
	 * @param key  省id
	 * @param key1   市id
	 * @param value
	 */
	public  void addCounty(String key,String key1,List<ProvinceBean> value){
		if (countyMap==null||map==null) {
			map=new HashMap<String, Map<String,List<ProvinceBean>>>();
			countyMap = new HashMap<String, List<ProvinceBean>>();
		}
		countyMap.put(key1, value);
		map.put(key, countyMap);
	}
	/**
	 * 获取县
	 * @param key  省id
	 * @param key1  市id
	 * @return
	 */
	public List<ProvinceBean> getCounty(String key,String key1){
		if (countyMap==null||map==null) {
			return null;
		}
		return map.get(key).get(key1);
	}
	

}
